\documentclass{tstextbook}


\begin{document}

\tsbook{\LaTeX~Book}
       {Author Name}
       {Cover Designer}
       {2017}
       {xxxxx}{xxx--xx--xxxx--xx--x}{0.0}
       {Publisher}
       {City}

%---------------------------------------------------------------------------
% Chapters
%---------------------------------------------------------------------------

%---------------------------------------------------------------------------
\chapter{First chapter}

\begin{summary}
  中文宏包测试               \par 
{\songti   这是宋体的样式。} 
{\heiti    这是黑体的样式。} 
{\fangsong 这是仿宋的样式。} 
{\kaishu   这是楷书的样式。} \par

This first chapter illustrates how to use various elements of this
  text book template, such as definitions, theorems and exercises. You
  may want to start each chapter with a meta summary like this one, to
  explain to the reader what the chapter is all about, why it is
  important and how it fits into the bigger picture of the
  book. Another useful tip is to put the contents of each chapter into
  a separate \LaTeX{} file and then use the command
  \texttt{\textbackslash{}input\{\}} to include the chapter in the
  main document.
\end{summary}

\section{First section}

\begin{lstlisting}[title=代码块1,language=Python]
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def mergeTwoLists(self, l1, l2):
        """
        :type l1: ListNode
        :type l2: ListNode
        :rtype: ListNode
        """
        head = ListNode(0)
        l3 = head
        
        while l1 and l2:
            if l1.val > l2.val:
                l3.next = ListNode(l2.val)
                l3 = l3.next
                l2 = l2.next
            else:
                l3.next = ListNode(l1.val)
                l3 = l3.next
                l1 = l1.next
        if l1:
            while l1:
                l3.next = ListNode(l1.val)
                l3 = l3.next
                l1 = l1.next
        if l2:
            while l2:
                l3.next = ListNode(l2.val)
                l3 = l3.next
                l2 = l2.next
        return head.next
\end{lstlisting}

Let's start out with the following theorem.

\begin{theorem}[Logic algebra]
  \label{th:logicalgebra}
  \index{logic algebra}
  Let $P$, $Q$ and $R$ be logical propositions (true or false).
  Then the following propositions are true:
  \small
  \begin{align*}
    P \land Q &\Leftrightarrow Q \land P &
    P \lor  Q &\Leftrightarrow Q \lor P  &&
    \text{(commutative laws)} \\
    (P \land Q) \land R &\Leftrightarrow P \land (Q \land R) &
    (P \lor Q)  \lor  R &\Leftrightarrow P \lor  (Q \lor  R) &&
    \text{(associative laws)} \\
    P \land (Q \lor  R) &\Leftrightarrow (P \land Q) \lor  (P \land R) &
    P \lor  (Q \land R) &\Leftrightarrow (P \lor  Q) \land (P \lor  R) &&
    \text{(distributive laws)} \\
    \lnot (P \land Q) &\Leftrightarrow \lnot P \lor  \lnot Q &
    \lnot (P \lor  Q) &\Leftrightarrow \lnot P \land \lnot Q &&
    \text{(De Morgan's laws)}
  \end{align*}
\end{theorem}
\begin{proof}
  \newcommand{\T}{\mathsf{T}}
  \newcommand{\TT}{\mathbf{T}}
  \renewcommand{\F}{\mathsf{F}}
  We prove the first of De Morgan's laws and leave the proofs of
  the remaining propositions as exercises. To prove the statement,
  we create a truth table and fill in all possible values (true or
  false) for the propositions $P$ and $Q$. Each of these propositions
  can be either true or false and we thus obtain the following truth
  table with four cases:
  \begin{center}
    \begin{tabular}{cccccccccc}
      $\lnot$ & ($P$ & $\land$ & $Q$) & $\Leftrightarrow$ & $\lnot$ & $P$ & $\lor$ & $\lnot$ & $Q$ \\
      \midrule
      & $\T$ && $\T$ &&& $\T$ &&& $\T$ \\
      & $\T$ && $\F$ &&& $\T$ &&& $\F$ \\
      & $\F$ && $\T$ &&& $\F$ &&& $\T$ \\
      & $\F$ && $\F$ &&& $\F$ &&& $\F$
    \end{tabular}
  \end{center}
  By definition of the logical operators, we compete the table to obtain
  \begin{center}
    \begin{tabular}{cccccccccc}
      $\lnot$ & ($P$ & $\land$ & $Q$) & $\Leftrightarrow$ & $\lnot$ & $P$ & $\lor$ & $\lnot$ & $Q$ \\
      \midrule
      $\F$ & $\T$ & $\T$ & $\T$ & $\TT$ & $\F$ & $\T$ & $\F$ & $\F$& $\T$ \\
      $\T$ & $\T$ & $\F$ & $\F$ & $\TT$ & $\F$ & $\T$ & $\T$ & $\T$& $\F$ \\
      $\T$ & $\F$ & $\F$ & $\T$ & $\TT$ & $\T$ & $\F$ & $\T$ & $\F$& $\T$ \\
      $\T$ & $\F$ & $\F$ & $\F$ & $\TT$ & $\T$ & $\F$ & $\T$ & $\T$& $\F$
    \end{tabular}
  \end{center}
  It follows that the statement we want to prove (the equivalence $\Leftrightarrow$)
  is always true (a \emph{tautology}), which proves the statement.
\end{proof}

\section{Second section}

We begin our next section with the following central definition.

\begin{definition}[Rational Cauchy sequence]
  \label{th:rationalcauchysequence}
  \index{rational Cauchy sequence}
  A rational Cauchy sequence is a rational sequence
  $(x_n)_{n=0}^{\infty}$ such that
  \begin{equation}
    \forall \epsilon \in \mathbb{Q}_+ \;
    \exists N \in \mathbb{N} : m, n \geq N \Rightarrow |x_m - x_n| < \epsilon.
  \end{equation}
  In other words, for each (small) rational number $\epsilon > 0$
  there is a (big) number $N$ such that the distance $|x_m - x_n|$
  between $x_m$ and $x_n$ is less than $\epsilon$ if both $m$ and $n$
  are larger than or equal to $N$.
\end{definition}

\begin{remark}
  A remark may be in order here. This definition is concerned with
  \emph{rational} Cauchy sequences. We will later encounter a similar
  definition of \emph{real} Cauchy sequences.
\end{remark}

\begin{example}[Solving the equation $x^2 = 2$]
  Consider the equation $x^2 = 2$. It is easy to prove that this
  equation does not have any rational solutions. However, consider
  the following iteration formula:
  \begin{equation}
    x_n = \frac{x_{n-1} + 2 / x_{n - 1}}{2},
  \end{equation}
  where $n = 1,2,3,\ldots$ and $x_0 = 1$. The resulting sequence of
  rational numbers quickly approaches a number in the vicinity of
  $x = 1.4142135623731$:
  \begin{displaymath}
    \begin{array}{rclcl}
      x_0 &=& 1 \\
      x_{1} &=& (x_{0} + 2 / x_{0}) / 2 &=& 1.5 \\
      x_{2} &=& (x_{1} + 2 / x_{1}) / 2 &\approx& 1.4166666666667 \\
      x_{3} &=& (x_{2} + 2 / x_{2}) / 2 &\approx& 1.4142156862745 \\
      x_{4} &=& (x_{3} + 2 / x_{3}) / 2 &\approx& 1.4142135623747 \\
      x_{5} &=& (x_{4} + 2 / x_{4}) / 2 &\approx& 1.4142135623731 \\
      x_{6} &=& (x_{5} + 2 / x_{5}) / 2 &\approx& 1.4142135623731 \\
      x_{7} &=& (x_{6} + 2 / x_{6}) / 2 &\approx& 1.4142135623731 \\
      x_{8} &=& (x_{7} + 2 / x_{7}) / 2 &\approx& 1.4142135623731 \\
      x_{9} &=& (x_{8} + 2 / x_{8}) / 2 &\approx& 1.4142135623731 \\
      x_{10} &=& (x_{9} + 2 / x_{9}) / 2 &\approx& 1.4142135623731
    \end{array}
  \end{displaymath}
  We will later see that this iteration, or any other equivalent
  iteration, defines the real number $\sqrt{2}$.
\end{example}

\section{Third section}

Now let's move on to the definition of the real number system. This
may be defined in a multitude of ways, one of which is to think about
a real number as a rational Cauchy sequence, or rather the equivalence
class of Cauchy sequences ``converging to'' that number.

\begin{definition}[The real numbers $\mathbb{R}$]
  \label{def:realnumbers}
  \index{real numbers}
  The real numbers $\mathbb{R}$ is the set of all equivalence classes
  of rational Cauchy sequences.
\end{definition}

Now that this is settled, lets prove the completeness of the real
number system.

\begin{theorem}[The completeness of the real numbers]
  \label{th:realnumberscomplete}
  \index{completeness of the real numbers}
  Let $(x_n)_{n=0}^{\infty}$ be a sequence of real numbers.
  Then $(x_n)_{n=0}^{\infty}$ is convergent if and only if
  it is also a real Cauchy sequence.
  \end{theorem}
\begin{proof}
  Write $x_m = [(x_{mn})_{n=0}^{\infty}]$ where
  $x_{mn}$ is the $n$th number in a rational Cauchy sequence
  representing the real number $x_m$. And so on\ldots.
\end{proof}

For further reading, there are several excellent works that one could
cite, such as \cite{Tao2006,Turing1936}.

\section*{Exercises}

\begin{exercise}
  Let $A = \{1, 2, 3\}$ and $B = \{2, 3, 4\}$.
  Determine the following sets. \\
  (a) $A \cup B$ \quad
  (b) $A \cap B$ \quad
  (c) $A \setminus B$ \quad
  (d) $A \times B$
\end{exercise}

\begin{exercise}
  Let $A = \{1, 3, 5, 7, 9\}$ and $B = \{2, 4, 6, 8, 10\}$.
  Determine the following sets. \\
  (a) $A \cup B$ \quad
  (b) $A \cap B$ \quad
  (c) $A \setminus B$ \quad
  (d) $A \times B$
\end{exercise}

\begin{exercise}
  Let $A = \{1, 2, 3\}$, $B = \{2, 3, 4\}$ and $C = \{3, 4, 5\}$.
  Determine the following sets. \\
  (a) $A \cup B \cup C$ \quad
  (b) $A \cap B \cap C$ \quad
  (c) $(B \setminus A) \cap C$ \quad
  (d) $(A \times B) \times C$
\end{exercise}

\section*{Problem}

\begin{problem}
  Interpret the following set definition (Russell's paradox) and discuss
  whether $X \in X$ or $X \notin X$:
  \begin{equation}
    X = \{x \mid x \notin x\}.
  \end{equation}
\end{problem}

\section*{Computer exercises}

\begin{programming}
  Write a program that generates the sequence $(x_n)_{n=0}^{100}$
  for $x_n = n$.
\end{programming}

\begin{programming}
  Write a program that generates the odd numbers between $1$ and $100$.
\end{programming}

\begin{programming}
  Write a program that computes the sum $\sum_{n=0}^{100} x_n$
  for $x_n = n$.
\end{programming}

%---------------------------------------------------------------------------
\chapter{Second chapter}

\begin{summary}
  \blindtext
\end{summary}

\section{First section}
\Blindtext

\section{Second section}
\Blindtext

\section{Third section}
\Blindtext

%---------------------------------------------------------------------------
\chapter{Third chapter}

\begin{summary}
  \blindtext
\end{summary}

\section{First section}
\Blindtext

\section{Second section}
\Blindtext

\section{Third section}
\Blindtext

%---------------------------------------------------------------------------
% Bibliography
%---------------------------------------------------------------------------

\addcontentsline{toc}{chapter}{\textcolor{tssteelblue}{Literature}}
\printbibliography{}

%---------------------------------------------------------------------------
% Index
%---------------------------------------------------------------------------

\printindex

\end{document}
